package com.heima.comment.controller;


import com.heima.comment.service.IApContentService;
import com.heima.model.comment.dtos.ApCommentDto;
import com.heima.model.comment.dtos.ApCommentLikeDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * 评论表 前端控制器
 *
 * @author leon
 * @since 2024-11-26
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/comment")
@RequiredArgsConstructor
public class ApContentController {

    @Autowired
    private final IApContentService apContentService;

    @PostMapping("/save")
    public ResponseResult save(@RequestBody ApCommentDto dto) {
        log.info("保存评论回复:{}", dto);
        return apContentService.submitComment(dto);
    }

    @PostMapping("/load")
    public ResponseResult load(@RequestBody  ApCommentDto dto) {
        log.info("获取评论:{}", dto);
        return apContentService.load(dto);
    }

    @PostMapping("/like")
    public ResponseResult like(@RequestBody ApCommentLikeDto dto) {
        log.info("点赞:{}", dto);
        return apContentService.like(dto);
    }

}
